<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>简化创建自定义对象的方式</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
	
	<!-- js方式定义Person对象
	<script type="text/javascript">
		function Person(id,name,sal){
			this.id = id;
			this.name = name;
			this.sal = sal;
		}
		var p = new Person(1,"波波",7000);
		document.write("编号:" + p.id + "<br/>");
		document.write("姓名:" + p.name + "<br/>");
		document.write("薪水:" + p.sal + "<br/>");
	</script>
	-->
	
	<hr/>
	
	<!-- json方式定义Person对象 -->
		<script type="text/javascript">
		//采用js语言来书写
		var p = {id:1,name:"包包",sal:8000};
		//属性可以''或""符号
		//字符串必加''或""符号，其它类型不用加符号
		document.write("编号:" + p.id + "<br/>");
		document.write("姓名:" + p.name + "<br/>");
		document.write("薪水:" + p.sal + "<br/>");
	</script>
  </body>
</html>



